package com.code.leetcode.idea;

public class LeetCodeIdea027 {
    public static void main(String[] args) {
//        String s = "()[]{}";
        int[] nums = new int[]{1,1,2};
        int val = 1;
        LeetCodeIdea027 leetCodeIdea027 = new LeetCodeIdea027();
        int length = leetCodeIdea027.removeElement(nums, val);
        System.out.println(length);

    }
    public int removeElement(int[] nums, int val) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int left = 0, right = 0;
        while (right < nums.length) {
            if (nums[right] != val) {
                nums[left] = nums[right];
                left++;
            }
            right++;
        }
        return left;
    }
}
